]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/texture-cache: Add missing error reporting
authorJonas Ådahl <jadahl@gmail.com>
Mon, 23 Mar 2026 12:26:51 +0000 (13:26 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 31 Mar 2026 07:39:16 +0000 (07:39 +0000)
st_texture_cache_load_file_sync_to_cogl_texture() loads a file into a
texture, but if pixbuf_to_st_content_image() failed, it'd return that it
failed, but wouldn't set an error, which would cause a null pointer
dereference when attempting to log the error message in the caller. Fix
this by setting an error on all error paths.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/9130
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4150>

src/st/st-texture-cache.c

index 2c7601da1a6377d5d987490c83b2a26f329f0baf..a30ebfa56a409e59a6a853d5c5227ae2595164b5 100644 (file)
@@ -488,15 +488,16 @@ load_pixbuf_async_finish (StTextureCache *cache, GAsyncResult *result, GError **
 }
 
 static ClutterContent *
-pixbuf_to_st_content_image (GdkPixbuf   *pixbuf,
-                            CoglContext *context,
-                            int          width,
-                            int          height,
-                            int          paint_scale,
-                            float        resource_scale)
+pixbuf_to_st_content_image (GdkPixbuf    *pixbuf,
+                            CoglContext  *context,
+                            int           width,
+                            int           height,
+                            int           paint_scale,
+                            float         resource_scale,
+                            GError      **error)
 {
   ClutterContent *image;
-  g_autoptr(GError) error = NULL;
+  g_autoptr(GError) local_error = NULL;
 
   float native_width, native_height;
 
@@ -533,11 +534,11 @@ pixbuf_to_st_content_image (GdkPixbuf   *pixbuf,
                              gdk_pixbuf_get_width (pixbuf),
                              gdk_pixbuf_get_height (pixbuf),
                              gdk_pixbuf_get_rowstride (pixbuf),
-                             &error);
+                             &local_error);
 
-  if (error)
+  if (local_error)
     {
-      g_warning ("Failed to allocate texture: %s", error->message);
+      g_propagate_error (error, g_steal_pointer (&local_error));
       g_clear_object (&image);
     }
 
@@ -702,13 +703,20 @@ finish_texture_load (AsyncTextureLoadData *data,
       if (!g_hash_table_lookup_extended (cache->keyed_cache, data->key,
                                          &orig_key, &value))
         {
+          g_autoptr (GError) error = NULL;
+
           image = pixbuf_to_st_content_image (pixbuf,
                                               data->cogl_context,
                                               data->width, data->height,
                                               data->paint_scale,
-                                              data->resource_scale);
+                                              data->resource_scale,
+                                              &error);
           if (!image)
-            goto out;
+            {
+              g_warning ("Failed to load pixbuf into a content: %s",
+                         error->message);
+              goto out;
+            }
 
           g_hash_table_insert (cache->keyed_cache, g_strdup (data->key),
                                g_object_ref (image));
@@ -720,13 +728,20 @@ finish_texture_load (AsyncTextureLoadData *data,
     }
   else
     {
+      g_autoptr (GError) error = NULL;
+
       image = pixbuf_to_st_content_image (pixbuf,
                                           data->cogl_context,
                                           data->width, data->height,
                                           data->paint_scale,
-                                          data->resource_scale);
+                                          data->resource_scale,
+                                          &error);
       if (!image)
-        goto out;
+        {
+          g_warning ("Failed to load pixbuf into a content: %s",
+                     error->message);
+          goto out;
+        }
     }
 
   if (data->icon_info)
@@ -1221,7 +1236,8 @@ st_texture_cache_load_file_sync_to_cogl_texture (StTextureCache *cache,
 
       image = pixbuf_to_st_content_image (pixbuf, context,
                                           available_height, available_width,
-                                          paint_scale, resource_scale);
+                                          paint_scale, resource_scale,
+                                          error);
       g_object_unref (pixbuf);
 
       if (!image)